#include "UdpServer.hpp"
#include <memory> //引入智能指针
#include "log.hpp"
void Usage(std::string proc)
{
    std::cout << "\r\nUsage: " << proc << "port[1024+]\n"
              << std::endl;
}
// c处理收到的字符串用的函数
std::string Handler(const std::string &str)
{
    std::string res = "Server get a message: ";
    res += str;
    std::cout << res << std::endl;
    return res;
}

//./udpserver port
int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        Usage(argv[0]);
        exit(0);
    }

    std::unique_ptr<UdpServer> svr(new UdpServer(8080)); // 创建一个服务器对象
    svr->Init();
    svr->Run(Handler);
    return 0;
}